cmake_minimum_required (VERSION 3.5)

message("---------------------- begin -----------------------")
message("PROJECT_SOURCE_DIR is ${PROJECT_SOURCE_DIR}") #当前CMakeLists.txt所在目录
message("PROJECT_BINARY_DIR is ${PROJECT_BINARY_DIR}") #当前的build目录
message("CMAKE_CURRENT_SOURCE_DIR is ${CMAKE_CURRENT_SOURCE_DIR}")
message("CMAKE_CURRENT_BINARY_DIR is ${CMAKE_CURRENT_BINARY_DIR}")

# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
message("cmd: ${_cmd}")
execute_process(COMMAND ${_cmd}
  RESULT_VARIABLE _res
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)
message("_res: ${_res};_out: ${_out};_err: ${_err};")
message(123456789132)

#变量和文件只会记录最后一个命令的结果
execute_process(COMMAND touch aaa.jpg
                COMMAND touch bbb.png
                COMMAND grep -E "png|jpg"
                COMMAND ls
				RESULT_VARIABLE _res
				OUTPUT_VARIABLE _out
				ERROR_VARIABLE _err
                OUTPUT_FILE _outfile
				ERROR_FILE _errfile)
message("_res: ${_res};_out: ${_out};_err: ${_err};")
message("_outfile: ${_outfile};_errfile: ${_errfile};")

#查找某些文件并构成一个文件列表变量
file(GLOB XX_FILE_LIST "${PROJECT_BINARY_DIR}/*.png" "${PROJECT_BINARY_DIR}/*.jpg")
message("XX_FILE_LIST is ${XX_FILE_LIST}")
#复制XX_FILE_LIST中的文件到顶层目录的 jpg/
file(COPY ${XX_FILE_LIST} DESTINATION "${PROJECT_SOURCE_DIR}/jpg")

#在build目录通过make install命令将文件copy的目的路径
install(FILES ${XX_FILE_LIST}
    DESTINATION "${PROJECT_SOURCE_DIR}/include/"
   )

message("---------------------- end -----------------------")

